{extend name="common/base" /}

{block name="tool_bar"}
<div class="layui-row">
    <div class="layui-col-xs10">
        <form class="layui-form" action="">
            <div class="layui-col-xs5" style="margin-left: 5px; line-height: 38px;">
                <div class="layui-form-item">
                    <input name="search_key" placeholder="请输入关键词搜索" value="{$search_key}" class="layui-input"
                           type="text">
                </div>
            </div>
            <div class="layui-col-xs4" style="margin-left: 5px; line-height: 38px;">
                <button class="layui-btn layui-btn-primary" lay-submit="" lay-filter="formDemo">
                    <i class="fa fa-search"></i>
                </button>
            </div>
        </form>
    </div>
    <div class="layui-col-md2 tr">
        <a href="{:url('taskadd')}" id="addkw" class="layui-btn layui-btn-sm">新增任务</a>
    </div>
</div>
{/block}

{block name="body"}
<div class="layui-tab layui-tab-brief">
    <ul class="layui-tab-title">
        {volist name="tabs" id="vo"}
        <li {if $tab === $key }class="layui-this" {/if}>
        <a href="{$vo.href}">{$vo.title}</a>
        </li>
        {/volist}
    </ul>
    <div class="layui-tab-content" style="margin-top: 10px;">
        <div class="layui-tab-item layui-show">
            <table class="layui-table" lay-skin="line">
                <tbody>
                <tr>
                    <td>任务ID</td>
                    <td>任务名称</td>
                    <td>消息名称</td>
                    <td>推送时间</td>
                    <td>已完成/应完成</td>
                    <td>任务状态</td>
                    <td>创建时间</td>
                    <td>完成时间</td>
                    <td style="width: 120px;">操作</td>
                </tr>
                {volist name="data_list" id="vo"}
                <tr>
                    <td>{$vo.id}</td>
                    <td>{$vo.title}</td>
                    <td>{$vo.msg_title}</td>
                    <td>{:date('Y-m-d H:i:s', $vo.push_time)}</td>
                    <td>{$vo.count}/{$vo.total} <i class="fa fa-refresh js-refresh" title="刷新"></i></td>
                    <td>{$status_list[$vo.status]}</td>
                    <td>{:date('Y-m-d H:i:s', $vo.create_time)}</td>
                    <td>{$vo.complete_time > 0 ? date('Y-m-d H:i:s', $vo.complete_time) : '---'}</td>
                    <td>
                        <a href="javascript:;" class="layui-btn layui-btn-warm layui-btn-xs js-stop" data-id="{$vo.id}">终止</a>
                        <a href="{:url('taskedit', ['id' => $vo['id']])}" class="layui-btn layui-btn-xs">编辑</a>
                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
            <div id="page">
                {$page|raw}
            </div>
        </div>
    </div>
</div>
{/block}

{block name="js"}
<script>
    layui.use(['jquery', 'layer'],function() {
        var $ = layui.jquery
        , layer = layui.layer;

        $('.js-stop').on('click', function () {
            layer.confirm('确认操作吗?', {icon: 3, title:'温馨提示'}, (index) => {
                requestPost({
                    url: "{:url('taskStopPost')}",
                    data:{id: $(this).data('id')}
                });
                layer.close(index);
            });
        });

        $('.js-refresh').on('click', function () {
            location.reload();
        });
    });
</script>
{/block}

{block name="css"}
<style>
    .fa-refresh:hover{color: #0bb20c;}
</style>
{/block}